package com.scsj.cloud.authority.common;

import java.net.MalformedURLException;

import javax.servlet.ServletRequest;
import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
import javax.servlet.annotation.WebListener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 请求监听器
 * @author caoxiubin
 * @date 20190516
 */
@WebListener
public class RequestListener implements ServletRequestListener{

	private final Logger logger=LoggerFactory.getLogger(this.getClass());
	
	@Override
	public void requestDestroyed(ServletRequestEvent servletRequest) {
		logger.info("请求被销毁==============================");
		
	}

	@Override
	public void requestInitialized(ServletRequestEvent servletRequest) {
		logger.info("请求被创建==============================");
		
		ServletRequest request = servletRequest.getServletRequest();
//		String host = request.getRemoteHost();
//		int port = request.getRemotePort();
//		
//		String protocol = request.getProtocol();
//		
//		String localAddr = request.getLocalAddr();
//		
//		String serverName = request.getServerName();
//		
//		int serverPort = request.getServerPort();
//		
//		request.getServletContext().getContextPath();
		
		try {
			request.getServletContext().getResource("0");
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		
	}
	
	
	
	

}
